
$(function () {
    var cArr=[];
    for(var i =1;i<=10;i++){
        var y = {id:i,text:i+'年'};
        cArr.push(y);
    }
    $('#reviewCycle').combobox(
        {
            data:cArr,
            valueField:'id',
            textField:'text',
            editable: false
        }
    );

    $('#changedCycle').combobox(
        {
            data:cArr,
            valueField:'id',
            textField:'text',
            editable: false
        }
    );
    /**
     * 绑定人员选择事件
     */
    $("#userIdName").textbox({
        iconWidth: 20,
        icons: [{
            iconCls: 'icon-add'
        }]
    });
    var isReview=[{id:'1',text:'是'},{id:'0',text:'否'}];
    $('#isReview').combobox({
        data: isReview,
        valueField: 'id',
        textField: 'text',
        editable: false,
        panelHeight: '200'
    });
    $('#isChanged').combobox({
        data: isReview,
        valueField: 'id',
        textField: 'text',
        editable: false,
        panelHeight: '200'
    });

    $("#danwei").textbox('setValue', danweiName).textbox('setText', danweiName);
    addcerTb(certificateId);
});

function queryComboData(code,queryId) {
    var pageId='#'+queryId;
    $.ajax({
        type: 'post',
        url: ROOT_PATH + '/permission/dictionary/queryDictionaryByDictionaryTypeCode.shtml',
        data: {code: code},
        dataType: "json",
        success: function (result) {
            $(pageId).combobox({
                data: result,
                valueField: 'id',
                textField: 'text',
                editable: false,
                panelHeight: '200'

            });
        }
    });
}

function addcerTb(certificateId) {
    var isHgData=[{id:'0',text:'复审'},{id:'1',text:'换证'}];
    $('#cerTb').datagrid({
        fitColumns: true,
        idField: 'id',
        rownumbers: true,
        sortOrder: true,
        singleSelect: true,
        striped: true,
        fit: false,
        url:ROOT_PATH + '/train/certificate/selectRecords.shtml',
        height: 300,
        queryParams: {
            certificateId: certificateId,
        },
        columns: [[
            {
                field: 'id', title: 'id', hidden:true,width: 20
            },
            {
                field: 'certificateId', title: 'certificateId', hidden:true,width: 20
            },
            {field: 'recordType', title: '登记种类', width: 100,
                formatter: function (value, row, index){
                    return row.recordType=='2'?'发证':(row.recordType=='0'?'复审':'换证');
                }},
            {field: 'certificateCode', title: '证书编号', width: 100},
            {field: 'time', title: '发证/复审/换证日期', width: 100},
            {field: 'nextTime',title: '下次复审/换证日期', width: 100},
            {field: 'addUserName', title: '登记人', width: 100},
            {field: 'addDeptName', title: '登记部门', width: 100},
            {field: 'addTime', title: '登记日期', width: 100},
        ]]
    });
}
